package com.ruoyi.web.controller.compensationManagement;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.compensationManagement.domain.CompensationStaffpayroll;
import com.ruoyi.compensationManagement.service.ICompensationStaffpayrollService;
import com.ruoyi.system.service.ISysCommonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 查看个人工资单Controller
 *
 * @author zy
 * @date 2022-10-22
 */

@RestController
@RequestMapping("/compensationManagement/viewSelfStaffpayroll")
public class CompensationViewSelfStaffpayrollController extends BaseController {
    @Autowired
    private ICompensationStaffpayrollService compensationStaffpayrollService;

    @Autowired
    private ISysCommonService sysCommonService;

    /**
     * 查询自身工资列表
     */

    @PreAuthorize("@ss.hasPermi('compensationManagement:viewSelfStaffpayroll:list')")
    @GetMapping("/list")
    public TableDataInfo list(CompensationStaffpayroll compensationStaffpayroll) {
        startPage();
        compensationStaffpayroll.setJobnumber(sysCommonService.getSysUserByUserId(getUserId()).getJobNumber());
        compensationStaffpayroll.setAuditStatus("Y");
        List<CompensationStaffpayroll> list = compensationStaffpayrollService.selectCompensationStaffpayrollList(compensationStaffpayroll);
        return getDataTable(list);
    }


    /**
     * 获取自身工资详细信息
     */
    @PreAuthorize("@ss.hasPermi('compensationManagement:viewSelfStaffpayroll:query')")
    @GetMapping(value = "/{staffpayrollId}")
    public AjaxResult getInfo(@PathVariable("staffpayrollId") Long staffpayrollId) {
        CompensationStaffpayroll compensationStaffpayroll = new CompensationStaffpayroll();
        compensationStaffpayroll.setJobnumber(sysCommonService.getSysUserByUserId(getUserId()).getJobNumber());
        return AjaxResult.success(compensationStaffpayrollService.selectCompensationStaffpayrollByStaffpayrollId(staffpayrollId));
    }

}
